#ifndef WINDOWCONTROLLER_H
#define WINDOWCONTROLLER_H

#include"../poco/windowInfo.h"
#include"../poco/saleBase.h"
#include"../poco/orderRoleBase.h"
#include"../poco/order.h"
#include"../poco/user.h"
#include<vector>
using std::vector;

class WindowController
{
public:
    WindowController();

    void setWindow(WindowInfo win_){win=win_;}

    void setSales(vector<SaleBase*> sales_){sales=sales_;};

    void setorderRoles(vector<OrderRoleBase*> orderRoles_){orderRoles=orderRoles_;};

    void setUser(User user_){user=user_;}

    WindowInfo getWindow(){return  win;}

    vector<SaleBase*> getSales(){return sales;}

    vector<OrderRoleBase*> getOrderRoles(){return orderRoles;}

    void clearOrder(){
        order.clear();
    }

    User getUser(){return user;}

    Order getOrder(){return order;}

    //为订单添加食物
    void addSelectSale(SaleBase* sale);

    //为订单添加优惠
    void addSelectOrderRole(OrderRoleBase* orderRole);

    //删除第i个选择的食物
    void delSelectSale(unsigned int i){
        if(i<order.sales.size())
            order.sales.erase(order.sales.begin()+i);
    }

    //删除所有的优惠
    void delAllOrderRole(){
        order.orderRoles.clear();
    }

    //删除第i个选择的优惠
    void delOrderRole(unsigned int i)
    {
        if(i<order.orderRoles.size())
            order.orderRoles.erase(order.orderRoles.begin()+i);
    }


    //结算，进行收费操作，数据库操作，返回收费是否成功
    bool checkOut();

    //为窗口添加菜
    bool addSale(SaleBase* sale);

    //为窗口添加优惠
    bool addOrderRole(OrderRoleBase* _order);


protected:
    User user;
    WindowInfo win;
    vector<SaleBase*> sales;
    vector<OrderRoleBase*> orderRoles;
    Order order;

};

#endif // WINDOWCONTROLLER_H
